/*
* Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Commondialog.qml.
*/

import QtQuick 1.0

/*!
 *  \file
 *  \brief Defines information dialog to shows notifications.
 *
 *  Dialog is used to show notifications when device is connected and
 *  when a shared laocation is received from the other device.
 */

Rectangle {
    id: informationDialog
    height: 150
    width: 300
    anchors.centerIn: parent
    color:  "white"
    opacity: 0.8
    radius:  5
    border.width: 1

    property string dialogText: "default text"

    Connections {
        target: locationManager
        onDeviceConnected: {
            dialogLabel.text = "Device " + deviceName + " connected."
            informationDialog.visible = true;
            closeDialogTimer.running = true;
            topMostView.sharing = true;
            clickEffect.play
            }

        onLocationReceived: {
            dialogLabel.text = "Location " + locationName + " received."
            informationDialog.visible = true;
            closeDialogTimer.running = true;
            clickEffect.play
            }

        onDeviceDisconnected: {
            dialogLabel.text = "Device " + deviceName + " disconnected."
            informationDialog.visible = true;
            closeDialogTimer.running = true;
            topMostView.sharing = false;
            clickEffect.play
            }
        }

    Rectangle {
        height: parent.height - 2 * radius
        width: parent.width - 2 * radius
        x: radius
        y: radius
        Text {
            id: dialogLabel
            x: radius
            y: radius
            anchors.fill:  parent
            font.bold: true;
            font.pixelSize: 25
            wrapMode: Text.Wrap
        }
    }

    Timer {
        id: closeDialogTimer
        interval: 3000;
        running: false;
        repeat: false
        onTriggered: informationDialog.visible = false;
    }
}
